import java.util.ArrayList;


public class temp {

	// Father(X,Y), Mother(X,Z) :- GrandFather(X,Y), dsdfspü, fewfr, ferg
	
	// X/Dennis,Y/Max,Z/
	
	// Persons
	
	public static String[] persons;
	public static double getFOILGain(Rule rule, ArrayList<Literal> pos, ArrayList<Literal> neg)
	{	
		ArrayList<String[]> allCombinations = new ArrayList<String[]>();
		for (String atom : persons) 
		{
			ArrayList<String[]> initialList = new ArrayList<String[]>();
			String[] initialValue = new String[1];
			initialValue[0] = atom;
			initialList.add(initialValue);
			
			allCombinations.addAll(calcSubstitutions(3, initialList));
		}
		
		return 0;
	}
	
	private static ArrayList<String[]> calcSubstitutions(int depth, ArrayList<String[]> currentCombi)
	{
		if (depth == 0)
			return currentCombi;
		
		ArrayList<String[]> newCombinations = new ArrayList<String[]>();
		
		for (int i = 0; i < currentCombi.size(); i++) 
		{
			for (int j = 0; j < persons.length; j++) 
			{
				// Check if person is already in current combination
				boolean isAlreadyInCombination = false;
				for (int j2 = 0; j2 < currentCombi.get(i).length; j2++) 
				{
					if (persons[i].equals(currentCombi.get(i)[j2]))
					{
						isAlreadyInCombination = true;
						break;
					}
				}
				
				if (isAlreadyInCombination) 
				{
					continue;
				}
				
				// Create new String Array for new Combination with one more Atom
				String[] tempCombi = new String[currentCombi.get(i).length + 1];
				for (int k = 0; k < currentCombi.get(i).length; k++) {
					tempCombi[k] = currentCombi.get(i)[k];
				}
				tempCombi[currentCombi.get(i).length] = persons[j];
				
				newCombinations.add(tempCombi);
			}
		}
		
		return calcSubstitutions(depth -1, newCombinations);
	}
}
